﻿Imports System.Data.SqlClient

Public Class frmIncaNuevos1
    Dim existenCargos As Boolean
    Dim Bitacora As New clsActividad
    Private Sub frmIncaNuevos1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CheckBox1.Checked = False

        Me.dgCargos.Rows.Clear()
        existenCargos = False

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT * From Incapacidades " & _
        " WHERE reportado='No' order by FechaInicio"

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader
        Dim nombre As String
        Dim f As Date

        Do While rdBuscar.Read()
            existenCargos = True
            f = rdBuscar("FechaInicio")
            nombre = BuscarStrDatoCitra("Empleados", "NombreCompleto", "IdEmpleado=" & rdBuscar("idempleado"))
            Me.dgCargos.Rows.Add(nombre, rdBuscar("serie"), rdBuscar("dias"), f.Day & "/" & f.Month & "/" & f.Year, rdBuscar("motivo"), rdBuscar("descripcion"))
        Loop

        If existenCargos = False Then
            Me.Close()

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click
        ToExcel(Me.dgCargos, "Relacion Incapacidades al " & Now())
    End Sub

    Private Sub RadButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton2.Click
        If Me.CheckBox1.Checked = True Then
            Call SetSqlCitra("Update Incapacidades set reportado='Si' where reportado='No'")
            Bitacora.RegistraActividad("Revisó las notificaciones de nuevas incapacidades")
            Me.Close()
        Else
            Me.Close()
        End If

    End Sub
End Class